package testsystem;

//import com.romaremez.testuser.src.admin.Admin;
/*import com.romaremez.testuser.src.userdata.*;
import com.romaremez.testuser.src.datautils.DataSaver;  */

import datautils.XMLQuestionSource;
import org.apache.log4j.Logger;
import questionanswer.Question;
import userdata.User;
import userdata.UserSession;

import java.util.List;

/**
 * Main application class, which starts the test
 *
 * @version 1.667
 * @author Roman Remez & Max Karasik
 */
public class TestStarter {

    private static final Logger logger = Logger.getLogger(TestStarter.class);

    public static void main(String[] args) {
        logger.error("Hello world!");
        new TestStarter().start();
        //TODO use this: List<Question> questions  = new XMLQuestionSource().getQuestions("questions.xml");
    }

    private void start() {
        DataBase dataBase = new DataBase();
        User user = dataBase.getUser();
        if (user.isAdmin()) {
            dataBase.displayUsersAndSessions();
        } else{
            UserSession userSession = dataBase.getSession(user);
            new TestUser(userSession).startTest();
            dataBase.save();
        }
    }

}
